'''
Created on Nov 19, 2010

@author: namikata
'''

import pygame
from pygame.locals import *

FONTTYPE = 0
IMAGETYPE = 1
IMAGETRANSTYPE = 2
SOUNDTYPE = 3
MUSICTYPE = 4
TEXTTYPE = 5

class Resources(object):
    '''
    classdocs
    '''

    dic = {}
    
    def __getattr__(self, key):
        return self.dic.get(key)
    
    def __init__(self,resources_file):
        '''
        Constructor
        '''
                
        reslist = open(resources_file,"r").readlines()
        
        for res in reslist:           
            res = res.replace("\n","").split(":")
            res[0] = int(res[0])
            
            if res[0] == FONTTYPE:
                D=8
                #load font
            elif res[0] == IMAGETYPE:
                #load image
                self.dic[res[1]] = pygame.image.load(res[2]).convert()
            elif res[0] == IMAGETRANSTYPE:
                #load image with transparency
                self.dic[res[1]] = pygame.image.load(res[2]).convert_alpha()
            elif res[0] == SOUNDTYPE:
                D=0
                #load sound
            elif res[0] == MUSICTYPE:
                D=0
                #load music
            elif res[0] == TEXTTYPE:
                #load text
                self.dic[res[1]] = res[2]